using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Threading;
using Hallenberg.SmartClient.Services;
using System.Globalization;
using Hallenberg.SmartClient.Interfaces;
using Microsoft.Practices.Unity;

namespace MenuDemo.Controllers
{
    public class LanguageController : Controller
    {
        [Dependency]
        public IResourceMapper ResourceMapper { get; set; }

        [Dependency]
        public ILocalization LocalizationHelper { get; set; }

        private void SetLanguage(string language)
        {
            this.ResourceMapper.ChangeLanguage(language, delegate(int newLCID)
            {
                this.LocalizationHelper.ChangeLanguage(newLCID);
            });
        }

        public ActionResult Danish()
        {
            SetLanguage("da-dk");

            return this.Redirect(this.Request.UrlReferrer.ToString());
        }

        public ActionResult English()
        {
            SetLanguage("en-us");

            return this.Redirect(this.Request.UrlReferrer.ToString());
        }
    }
}
